//
//  MakeViewController.swift
//  Bee
//
//  Created by kyson on 15/12/31.
//  Copyright © 2015年 kyson. All rights reserved.
//

import UIKit

class MakeViewController: IGViewController{
    
    var editcellAdapter:EditCellAdapter!
    var themeCellAdapter:ThemeCellAdapter!
    var typeCellAdapter:TypeCellAdapter!
    
    var imageView1:UIImageView!
    var imageView2:UIImageView!

    @IBOutlet weak var pageTurnRightButton: UIButton!
    @IBOutlet weak var pageTurnLeftButtoon: UIButton!
    
    @IBOutlet weak var themeCollectionView: UICollectionView!
    @IBOutlet weak var typeCollectionView: UICollectionView!
    @IBOutlet weak var mEditCollectionView: UICollectionView!
    @IBOutlet weak var editScrollView: UIScrollView!
    @IBOutlet weak var collectionViewsContainerView: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let editPicNib = UINib.init(nibName: "EditPicCell", bundle: nil)
        mEditCollectionView.registerNib(editPicNib, forCellWithReuseIdentifier: "editpic")
        editcellAdapter = EditCellAdapter.init()
        mEditCollectionView.delegate = editcellAdapter
        mEditCollectionView.dataSource = editcellAdapter
        
        let themeNib = UINib.init(nibName: "ThemeCell", bundle: nil)
        themeCollectionView.registerNib(themeNib, forCellWithReuseIdentifier: "theme")
        themeCellAdapter = ThemeCellAdapter.init()
        themeCollectionView.delegate = themeCellAdapter
        themeCollectionView.dataSource = themeCellAdapter
        
        let typeNib = UINib.init(nibName: "TypeCell", bundle: nil)
        typeCollectionView.registerNib(typeNib, forCellWithReuseIdentifier: "type")
        typeCellAdapter = TypeCellAdapter.init()
        typeCollectionView.delegate = typeCellAdapter
        typeCollectionView.dataSource = typeCellAdapter
        
        if(DeviceType.IS_IPHONE_4_OR_LESS){
            editScrollView.contentSize = CGSizeMake(UIScreen.mainScreen().bounds.width * 2, 205)
        }else if(DeviceType.IS_IPHONE_5){
            editScrollView.contentSize = CGSizeMake(UIScreen.mainScreen().bounds.width * 2, 205)
        }else if(DeviceType.IS_IPHONE_6){
            editScrollView.contentSize = CGSizeMake(UIScreen.mainScreen().bounds.width * 2, 205)
        }else if(DeviceType.IS_IPHONE_6P){
            editScrollView.contentSize = CGSizeMake(UIScreen.mainScreen().bounds.width * 2, 350)
        }
        
        let image1 = UIImage.init(named: "about_bg")
        imageView1 = UIImageView.init(image: image1)
        imageView1.contentMode = UIViewContentMode.ScaleToFill
        imageView1.frame = CGRectMake(15, 0, editScrollView.width - 30, editScrollView.height)
        editScrollView.addSubview(imageView1)
        
        let image2 = UIImage.init(named: "about_bg")
        imageView2 = UIImageView.init(image: image2)
        imageView2.contentMode = UIViewContentMode.ScaleToFill
        imageView2.frame = CGRectMake(UIScreen.mainScreen().bounds.width + 15, 0, editScrollView.width - 30, editScrollView.height)
        editScrollView.addSubview(imageView2)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    override func viewDidLayoutSubviews() {
        
        if(DeviceType.IS_IPHONE_4_OR_LESS){
            
        }else if(DeviceType.IS_IPHONE_5){

            
        }else if(DeviceType.IS_IPHONE_6){
            
        }else if(DeviceType.IS_IPHONE_6P){
            imageView1.height = editScrollView.height
        }
        imageView1.height   = editScrollView.height
        imageView1.width    = editScrollView.width - 30
        imageView2.height   = editScrollView.height
        imageView2.width    = editScrollView.width - 30

    }
    
    @IBAction func buttonDidClicked(sender: UIButton) {
        switch(sender.tag){
        case 100:
            self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
            break
        case 101:
            break
        case 200:
            editScrollView.setContentOffset(CGPointMake(0, 0), animated: true)
            break
        case 201:
            editScrollView.setContentOffset(CGPointMake(ScreenSize.SCREEN_WIDTH, 0), animated: true)
            break
            
            
        default:
            break
        }
    }
    
}


